****************************************************
*Where do UN Patrols Go? Exploring UNAMIS Response *
*to Violence in Darfur 							   *
*Luke Abbs (University of Essex)				   *	
*Allard Duursma (ETH-Zurich)					   *
****************************************************

use "Peacekeeping_Darfur_Vol1.7_LA_AD.dta", clear

tsset gid duration

set more off

*****************************************
*Contents								*
*Prio-Grid								*
*(1) main results - Prio-grid			*
*(2) Long-distance patrols - Prio-grid	*
*(3) proactive patrols - Prio-grid	    *			
*(4) robustness	checks (focused on Prio)*
*****************************************

**************
*Main Results*
**************

*************
* PRIO GRID *
*************

*structured as following:
*model 1 - all variables with Prio-grid
*model 2 - all variables and interactions with Prio-grid

*Table 1

*models 1 and 3 UN patrols
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
eststo model1
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag base_armedclash base_civtarget base_ngo base_idp, vce(cluster gid)
eststo model2
esttab model1 model2, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*table
esttab model1 model2 using table1a.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*marginal effects

*full model
estsimp logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
setx mean 
simqi, pr
*.0010389

*armed violence dummy (1 versus 0)
setx armedclash_dum 0
simqi, pr
*.0025682 
setx armedclash_dum 1
simqi, pr
*.006083 (137% increase - large increase of just over 2 times more likely...) 

*civtarget (no events versus at least 1 event)
setx civtarget_dum 0
simqi, pr
*.0010151 
setx civtarget_dum 1
simqi, pr
*.0026018 (156% increase - again just over 2 times more likely) 

*UN base dummy (1 versus 0)
setx un_base_dum 0
simqi, pr
*.0052049 
setx un_base_dum 1
simqi, pr
*.0191298 (268% increase - large increase of just under 3 times more likely...) 
drop b1 - b20

*margins for interaction
*shows no significant evidence of dependence on UN bases
*dummy civilian violence

logit patrol_dum i.un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag base_armedclash base_civtarget base_ngo base_idp, vce(cluster gid)
margins un_base_dum, at(civtarget_dum=(0(1)1)) atmeans
marginsplot

*********************************************************
*Outside UN zones of influence/deployment (i.e. bunkers)*
*(long-distance UN Patrols							    *
*********************************************************

*Table 2

*model 5 patrols outside 15km
logit outside_15km_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol15 patrol15_spline1 patrol15_spline2 patrol15_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
eststo model5
esttab model5, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*model 6 patrols outside 25km
logit outside_25km_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol25 patrol25_spline1 patrol25_spline2 patrol25_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
eststo model6
esttab model6, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*Table 2
esttab model5 model6 using table2a_longpatrols.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*marginal effects for model 12 - i.e. more than 25km from base

*full model
*gen civtarget_dum=civtarget
*recode civtarget_dum 1/1000=1
estsimp logit outside_25km_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol25 patrol25_spline1 patrol25_spline2 patrol25_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
setx mean 
simqi, pr
*.00004278
*much much rarer this far from base!

*armed violence dummy (1 versus 0)
setx armedclash_dum 0
simqi, pr
*.0004222
setx armedclash_dum 1
simqi, pr
*.0011578 (increases to 174% or nearly three times more likely) 

*civtarget (no events versus at least 1 event)
setx civtarget_dum 0
simqi, pr
*.0011375 
setx civtarget_dum 1
simqi, pr
*.0025003 (120% increase - again just over 2 times more likely) 
drop b1 - b20

*IDP camps (dummy)
gen idp_camp_dum=no_idp_camp
recode idp_camp_dum 1/18=1
estsimp logit outside_25km_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo idp_camp_dum chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol25 patrol25_spline1 patrol25_spline2 patrol25_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
setx mean
*no IDP camps
setx idp_camp_dum 0
simqi, pr
*.0001760
*vs. IDP camps
setx idp_camp_dum 1
simqi, pr
*.0012141 (590% increase - nearly 7 times more likely) 
drop b1 - b20


************************
* Proactive UN Patrols *
************************

*Table 3

*Proactive Patrols Only - counter reporting bias - more likely to be
*reported when violence occurs

*models 9 and 11

logit proactive_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 propatrol_spline3 patrol_sp_lag base_sp_lag, vce(cluster gid)
eststo model9
logit proactive_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_propatrol propatrol_spline1 propatrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag base_armedclash base_civtarget base_ngo base_idp, vce(cluster gid)
eststo model10
esttab model9 model10, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

*Table 3
esttab model9 model10 using table3a_proactive.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 



*******************
*Robustness Checks*
*******************

*(1) Relative capacity of UN peacekeepers - changing UN base to number of troops

*models 1 and 3 rerun with number of troops in grid containing a base(s)
logit patrol_dum notroops_log sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag troops_sp_lag , vce(cluster gid)
eststo model1r1
logit patrol_dum notroops_log sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag troops_sp_lag troops_armedclash troops_civtarget troops_ngo troops_idp, vce (cluster gid)
eststo model2r1

esttab model1r1 model2r1, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
esttab model1r1 model2r1 using table_4R.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*(2) Robust standard errors
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag, robust cluster (gid)
eststo model1r2
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag base_armedclash base_civtarget base_ngo base_idp, robust cluster (gid)
eststo model2r2
esttab model1r2 model2r2, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)


*(3) Rare-events Logit

*install relogit
net install relogit, from(http://fmwww.bc.edu/RePEc/bocode/r)

gen l_armedclash_dum=l.armedclash_dum
gen l_civtarget_dum =l.civtarget_dum

relogit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l_armedclash_dum civtarget_dum l_civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag, cluster (gid)
eststo model1r3
relogit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l_armedclash_dum civtarget_dum l_civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag base_armedclash base_civtarget base_ngo base_idp, cluster (gid)
eststo model2r3
esttab model1r2 model2r2 model1r3 model2r3, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

esttab model1r2 model2r2 model1r3 model2r3 using table_5_6R.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


*(4) Inverse-Distance Spatial Lags

logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag un_base_inv_splag, vce(cluster gid)
eststo model1r4
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag un_base_inv_splag armedclash_inv_splag civtarget_inv_splag ngo_inv_splag idp_inv_splag, vce(cluster gid)
eststo model2r4

esttab model1r4 model2r4, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)

esttab model1r4 model2r4 using table_7.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 

* (5) Matching

ssc install cem
sort gid yearweek
by gid: gen armedclash_dum_lag = armedclash_dum[_n-1]
by gid: gen civtarget_dum_lag = civtarget_dum[_n-1]

*matching armedclash_dum
imb un_base_dum sum_road_events ttime civtarget_dum_lag armedclash_dum_lag ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 base_sp_lag, treatment(armedclash_dum)
cem un_base_dum sum_road_events ttime civtarget_dum_lag armedclash_dum_lag  ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 base_sp_lag, treatment(armedclash_dum)
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum armedclash_dum_lag civtarget_dum_lag ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 base_sp_lag [iweight=cem_weights], vce(cluster gid)
eststo match1


*matching civtarget_dum
imb un_base_dum sum_road_events ttime armedclash_dum_lag civtarget_dum_lag ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 base_sp_lag, treatment(civtarget_dum)
cem un_base_dum sum_road_events ttime armedclash_dum_lag civtarget_dum_lag ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 base_sp_lag, treatment(civtarget_dum)
logit patrol_dum un_base_dum sum_road_events ttime armedclash_dum_lag civtarget_dum_lag civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 base_sp_lag [iweight=cem_weights], vce(cluster gid)
eststo match2

esttab match1 match2, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001)
esttab match1 match2 using matching_PRIO.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 


* (6) Fixed Effects

clear
use "Peacekeeping_Darfur_Vol1.7_LA_AD.dta", clear
tsset gid duration
set more off

*week fixed effects
xtlogit patrol_dum armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum weeks_last_patrol patrol_sp_lag i.yearweek, fe 
eststo FE1

*grid fixed effects
xtlogit patrol_dum un_base_dum sum_road_events ttime armedclash_dum l.armedclash_dum civtarget_dum l.civtarget_dum ngo no_idp_camp chad_border mountains_meanmountainousterrain pop2005_log gcp2005_log weeks_last_patrol patrol_spline1 patrol_spline2 patrol_spline3 patrol_sp_lag base_sp_lag i.gid, fe
eststo FE2

esttab FE1 FE2 using FE_PRIO.rtf, se b(%10.3f) scalars("Oberservations" "aic AIC" "bic BIC" "ll Log lik." "chi2 Chi-squared") star(+ 0.10 * 0.05 ** 0.01 *** 0.001) 
